package com.gtfrank.web.servlet.service.impl;

import com.gtfrank.web.servlet.dao.IUserDao;
import com.gtfrank.web.servlet.dao.impl.UserDaoImpl;
import com.gtfrank.web.servlet.pojo.User;
import com.gtfrank.web.servlet.service.IUserService;

import java.util.List;

/**
 * @ProjectName: sudacoursetrainging
 * @ClassName: UserServiceImpl
 * @PackageName:com.gtfrank.web.servlet.service.impl
 * @Description:
 * @Author: frank
 * @Date: 2021/4/28 16:18
 * @Version v1.0
 */
public class UserServiceImpl implements IUserService {
    private IUserDao userDao = new UserDaoImpl();
    @Override
    public User login(String name, String password) {
        return userDao.findUserByNameAndPassword(name,password);
    }

    @Override
    public void register(User user) {
        userDao.addUser(user);
    }

    @Override
    public List queryAll() {
        return userDao.findAll();
    }

    @Override
    public void delete(int id) {
        userDao.deleteUser(id);
    }

    @Override
    public User getUserById(int id) {
        return userDao.findById(id);
    }

    @Override
    public void update(User user) {
        userDao.updateUser(user);
    }

    @Override
    public User findUserByName(String name) {
        return userDao.findByName(name);
    }

    @Override
    public List<User> findUserByLikeName(String name) {
        return userDao.findByLikeName(name);
    }
}
